<div class="layuimini-main">

    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">车位编号</label>
            <div class="layui-input-block">
                <input type="text" name="numbers" lay-verify="required" lay-reqtext="车位编号不能为空"
                       placeholder="请输入车位编号" value="" class="layui-input">
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label required">关联户主</label>
            <div class="layui-input-block">
                <select name="ownerId" lay-verify="required"  id="typeId" lay-search="">
                    <option value="">请关联户主</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remarks" class="layui-textarea" placeholder="请输入备注信息"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            laydate=layui.laydate,
            $ = layui.$;

        // 日期
        // laydate.render({
        //     elem: '#date',
        //     trigger:'click'
        // });
        form.render();
        //查询所有的楼宇信息并渲染到select中
        $.get("owner/queryAll",{},function (data) {
            var list=data;
            var select =document.getElementById("typeId");
            if(list!=null || list.size()>0){
                for(var c in list){
                    var option=document.createElement("option");
                    option.setAttribute("value",list[c].id);
                    option.innerText=list[c].username;
                    select.appendChild(option);
                }
            }
            form.render('select');
        },"json");



        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            //获取表单中的数据信息
            var datas=data.field;
            addOrUpdateSubmit($,"parking/add",datas);
            return false;
        });

    });
</script>